//
//  DSZMineViewController.m
//  7.13苏宁框架
//
//  Created by app05 on 15/7/16.
//  Copyright (c) 2015年 lovena. All rights reserved.
//

#import "DSZMineViewController.h"
#import "DSZMainHeaderView.h"
#import "DSZStyleOneCell.h"
#import "DSZStyleTwoCell.h"
#import "DSZStyleTTViewCell.h"
#import "DSZSettingViewController.h"
#import "DSZMineQianbaoViewController.h"
#import "DSZLoginViewController.h"
#import "DSZHuoDongViewController.h"
#import "DSZGuanZhuViewController.h"
#import "DSZDingDanViewController.h"
#import "DSZMainViewController.h"
#import "DSZDZFViewController.h"
#import "DSZDSHViewController.h"
#import "DSZDPJViewController.h"
#import "DSZTHZViewController.h"
#import "DSZWDYFBViewController.h"
#import "DSZWDYHJViewController.h"
#import "DSZWDYZViewController.h"
#import "DSZLQBViewController.h"
@interface DSZMineViewController ()<settingViewDelegate,cellStyleTwoDelegate,cellStyleTTDelegate>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,weak)DSZMainHeaderView*headerView;
@end

@implementation DSZMineViewController

- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBarHidden=YES;
    DSZMainViewController *main=(DSZMainViewController*)self.tabBarController;
    [main hiddenMainTabbar:NO];
    
    
    // 读取上次的配置
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *str = [defaults objectForKey:@"zh2"];
    NSLog(@"%@",str);
    if ([str isEqualToString:@"disizu"]) {
        _headerView.fisView.hidden=NO;
        _headerView.secView.hidden=YES;
    }
    else
    {
        _headerView.fisView.hidden=YES;
        _headerView.secView.hidden=NO;
    }

}
- (void)viewDidAppear:(BOOL)animated
{
    self.navigationController.navigationBarHidden=YES;
}
-(BOOL)prefersStatusBarHidden
{
    return YES;
}
- (void)viewDidLoad {
    [super viewDidLoad]; 
    self.tableView=[[UITableView alloc]initWithFrame:self.view.bounds];
    self.tableView.backgroundColor=[UIColor clearColor];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    self.tableView.showsVerticalScrollIndicator=NO;
    DSZMainHeaderView *header=[DSZMainHeaderView header];
    header.delegate1=self;
    self.tableView.tableHeaderView=header;
    self.tableView.userInteractionEnabled=YES;
    [self.view addSubview:self.tableView];
    _headerView=header;
}
-(void)settingBtnPush
{
    DSZSettingViewController *setting=[[DSZSettingViewController alloc]init];
    [self.navigationController pushViewController:setting animated:YES];
    self.navigationController.navigationBarHidden=NO;
}
-(void)loginInto
{
    DSZLoginViewController *loginC=[[DSZLoginViewController alloc]init];
    [self.navigationController pushViewController:loginC animated:YES];
    self.navigationController.navigationBarHidden=NO;
    DSZMainViewController *main=(DSZMainViewController*)self.tabBarController;
    [main hiddenMainTabbar:YES];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==1&&indexPath.row==0) {
        DSZMineQianbaoViewController *qb=[[DSZMineQianbaoViewController alloc]init];
        [self.navigationController pushViewController:qb animated:YES];
        self.navigationController.navigationBarHidden=NO;
    }else if (indexPath.section==0&&indexPath.row==0)
    {
        DSZDingDanViewController *qb=[[DSZDingDanViewController alloc]init];
        [self.navigationController pushViewController:qb animated:YES];
        self.navigationController.navigationBarHidden=NO;
    }
    else if (indexPath.section==2&&indexPath.row==0)
    {
        DSZGuanZhuViewController *qb=[[DSZGuanZhuViewController alloc]init];
        [self.navigationController pushViewController:qb animated:YES];
        self.navigationController.navigationBarHidden=NO;
    }else if (indexPath.section==2&&indexPath.row==1)
    {
        DSZHuoDongViewController *qb=[[DSZHuoDongViewController alloc]init];
        [self.navigationController pushViewController:qb animated:YES];
        self.navigationController.navigationBarHidden=NO;
    }
    DSZMainViewController *main=(DSZMainViewController*)self.tabBarController;
    [main hiddenMainTabbar:YES];
}
-(void)clickStyleTwoOfOrderWithSender:(UIButton *)sender
{
    if (sender.tag==0) {
        
        DSZDZFViewController *DZF=[[DSZDZFViewController alloc]init];
        [self.navigationController pushViewController:DZF animated:YES];
        self.navigationController.navigationBarHidden=NO;
        
    }
    else if (sender.tag==1)
    {
        DSZDSHViewController *DSH=[[DSZDSHViewController alloc]init];
        [self.navigationController pushViewController:DSH animated:YES];
        self.navigationController.navigationBarHidden=NO;
    }
    else if (sender.tag==2)
    {
        DSZDPJViewController *DPJ=[[DSZDPJViewController alloc]init];
        [self.navigationController pushViewController:DPJ animated:YES];
        self.navigationController.navigationBarHidden=NO;
    }
    else
    {
        DSZTHZViewController *THZ=[[DSZTHZViewController alloc]init];
        [self.navigationController pushViewController:THZ animated:YES];
        self.navigationController.navigationBarHidden=NO;

    }

    DSZMainViewController *main=(DSZMainViewController*)self.tabBarController;
    [main hiddenMainTabbar:YES];
}
-(void)clickStyleTwoOfMoneyWithSender:(UIButton *)sender
{
    if (sender.tag==0) {
        DSZWDYFBViewController *THZ=[[DSZWDYFBViewController alloc]init];
        [self.navigationController pushViewController:THZ animated:YES];
        self.navigationController.navigationBarHidden=NO;
    }else if (sender.tag==1)
    {
        DSZWDYHJViewController *THZ=[[DSZWDYHJViewController alloc]init];
        [self.navigationController pushViewController:THZ animated:YES];
        self.navigationController.navigationBarHidden=NO;
    }else if (sender.tag==2)
    {
        DSZWDYZViewController *THZ=[[DSZWDYZViewController alloc]init];
        [self.navigationController pushViewController:THZ animated:YES];
        self.navigationController.navigationBarHidden=NO;
    }
    else
    {
        DSZLQBViewController *THZ=[[DSZLQBViewController alloc]init];
        [self.navigationController pushViewController:THZ animated:YES];
        self.navigationController.navigationBarHidden=NO;
    }
    DSZMainViewController *main=(DSZMainViewController*)self.tabBarController;
    [main hiddenMainTabbar:YES];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==0) {
        return 2;
    }else if(section==1)
        return 2;
    else
        return 2;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell=nil;
    if (indexPath.section==0)
    {
        if (indexPath.row==0)
        {
            DSZStyleOneCell *cellOne=[DSZStyleOneCell cell1];
            cell=cellOne;
        }else
        {
            DSZStyleTwoCell *cellTwo=[DSZStyleTwoCell cellTwo1];
           
            cellTwo.delegate=self;
            cell=cellTwo;
        }
    }else if (indexPath.section==1)
    {
        if (indexPath.row==0) {
            DSZStyleOneCell *cellOne=[DSZStyleOneCell cell2];
            cell=cellOne;
        }
        else
        {
            DSZStyleTTViewCell *cellTwo=[DSZStyleTTViewCell cellTwo2];
            cellTwo.delegate=self;
            cell=cellTwo;
        }
    }else
    {
        if (indexPath.row==0) {
            DSZStyleOneCell *cellOne=[DSZStyleOneCell cell3];
            cell=cellOne;
        }else
        {
            DSZStyleOneCell *cellOne=[DSZStyleOneCell cell4];
            cell=cellOne;
        }
        
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0||indexPath.section==1) {
        if (indexPath.row==0) {
            return 34;
        }else
            return 60;
    }
    else
        return 34;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (section==2) {
        return 0;
    }
    return 20;
}
@end
